import logging
from logging.handlers import RotatingFileHandler



class Log:
    def __init__(self,logfile):
		LOGFILE =logfile 
		MAXLOGSIZE = 10*1024*1024 #Bytes
		BACKUPCOUNT = 4
		FORMAT = \
		"%(asctime)s %(levelname)-8s[%(filename)s:%(lineno)d] %(message)s"
		LOGLVL = logging.DEBUG
		handler = RotatingFileHandler(LOGFILE,
                              mode='a',
                              maxBytes=MAXLOGSIZE,
                              backupCount=BACKUPCOUNT)
		formatter = logging.Formatter(FORMAT)
		handler.setFormatter(formatter)
		self.LOG = logging.getLogger()
		self.LOG.setLevel(LOGLVL)
		self.LOG.addHandler(handler)
	def logDebug(self,s):
		self.LOG.debug(s)	
	def logInfo(self,s):
		self.LOG.info(s)
	def logError(self,s):
		self.LOG.error(s)

#loghandler = Log("./log/test.log")
#loghandler.logDebug("aaaaaaaaaaaaaaaaaaaa")
